/*
 *  Copyright 2010 INFN - APE group
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

#pragma once

#include <cuqu/config.h>

//#include <cuqu/detail/barrier_oneloop.h>
//#include <cuqu/detail/barrier_lockfree.h>

#if 0
#    include <cuqu/detail/barrier_shm.h>
#    define CUQU_INIT_BARRIER CUQU_INIT_BARRIER_SHM
#    define CUQU_BARRIER barrier_shm
#elif 0
#    include <cuqu/detail/barrier_simple.h>
#    define CUQU_INIT_BARRIER CUQU_INIT_BARRIER_SIMPLE
#    define CUQU_BARRIER barrier_simple
#elif 1
#    include <cuqu/detail/barrier_oneloop.h>
#    define CUQU_INIT_BARRIER CUQU_INIT_BARRIER_ONELOOP
#    define CUQU_BARRIER barrier_oneloop
#elif 0
#    include <cuqu/detail/barrier_lockfree.h>
#    define CUQU_INIT_BARRIER CUQU_INIT_BARRIER_LOCKFREE
#    define CUQU_BARRIER barrier_lockfree
#elif 0
#    include <cuqu/detail/barrier_tree_based.h>
#    define CUQU_INIT_BARRIER CUQU_INIT_BARRIER_TREE_BASED
#    define CUQU_BARRIER barrier_tree_based
#endif

#define __CUQU_BARRIER_NAME(STR) "cuqu::" #STR
#define CUQU_BARRIER_NAME(STR) __CUQU_BARRIER_NAME(STR)
#define CUQU_BARRIER_STR CUQU_BARRIER_NAME(CUQU_BARRIER) 

namespace cuqu
{
    namespace detail
    {
        typedef CUQU_BARRIER barrier_t;

        template <typename B> struct barrier
        {
            B m_barr;
            __device__ int wait(int n_waiters) { return barrier_wait(&m_barr, n_waiters); }
        };
    }
}

/*
 * Local variables:
 *  mode: c++
 *  c-indent-level: 4
 *  c-basic-offset: 4
 *  tab-width: 4
 *  indent-tabs-mode: nil
 * End:
 */
